<?php 

class Idiomas_model extends CI_Model{ 
	private $_tabla = 'Idiomas';
	public $idIdioma = 0;
    public $descripcion = "";
    public $estado = true;

    public function getAll(){
    	return $this->db->get($this->_tabla)->result_array();
    }
    public function insert(){
    	$this->db->insert($this->_tabla,$this);
    }

    public function update(){
		$this->db->where('idIdioma', $this->idIdioma);
		$this->db->update($this->_tabla,$this);
	}
	public function getById($id){
	$query = $this->db->query("SELECT * FROM " . $this->_tabla . " WHERE idIdioma = '" . $id . "'");

	 foreach ($query->result() as $row)
	 {
		return $row;
	 }
    }

      //by rube :$
    public function Buscador($patron,$tipo){
        $query = $this->db->query("SELECT * FROM ". $this->_tabla . " WHERE estado = '" . $tipo . "' AND descripcion LIKE '%" . $patron . "%'");
        return $query->result_array();
    }   

    public function getAllByEstado($tipo){
        $this->db->where('estado',$tipo);
        return $this->db->get($this->_tabla)->result_array();
    }

    public function baja_alta_Logica($id,$valor){
        $data = array('estado'=>$valor);
        $this->db->where('idIdioma',$id);
        $this->db->update($this->_tabla,$data);
    }
    // by rube :$


}
  ?>
